package com.jintian.smart.kernel.flowable.service;

import com.jintian.smart.kernel.flowable.context.DefaultProcessContext;
import com.jintian.smart.kernel.flowable.domain.entity.FlowComment;
import com.jintian.smart.kernel.flowable.mapper.IFlowCommentMapper;
import com.jintian.smart.kernel.orm.impl.AbstractEntityServiceImpl;
import com.jintian.smart.kernel.orm.service.IService;
import org.springframework.stereotype.Service;

@Service
public class CommentService extends AbstractEntityServiceImpl<IFlowCommentMapper, FlowComment> implements IService<FlowComment> {
    public void finish(DefaultProcessContext context) {
        if (context == null) {
            return;
        }
        FlowComment comment = this.query().andEq(FlowComment::getPid, context.getProcessInstanceId()).andEq(FlowComment::getTid, context.getTaskId()).single();
        if (comment != null) {
            comment.setStatus(1);
            this.updateById(comment);
        }
    }
}
